{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "InstrumentKit Example Library"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Keithley 6514 Electrometer"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%pylab inline\n",
      "import instruments as ik"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Populating the interactive namespace from numpy and matplotlib\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Here, our device is connected via a gpibusb adaptor, on COM5, address 14."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "elec=ik.keithley.Keithley6514.open_gpibusb('COM5', 14)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Now we query a few standard bits of information:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print elec.query('*IDN?')\n",
      "print \"Mode: {}\".format(elec.mode.value)\n",
      "print \"Unit: {}\".format(elec.unit)\n",
      "print \"Upper Range Limit: {}\".format(elec.input_range)\n",
      "print \"Zero Check: {}\".format(elec.zero_check)\n",
      "print \"Zero Correct: {}\".format(elec.zero_correct)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "KEITHLEY INSTRUMENTS INC.,MODEL 6514,1344784,A12   Aug 29 2008 15:40:25/A02  /D\n",
        "Mode: CURR:DC\n",
        "Unit: 1 A (ampere)"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Upper Range Limit: 2.1e-10 A"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Zero Check: False\n",
        "Zero Correct: False"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Set up the zero checking/correcting:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "elec.zero_check = False\n",
      "elec.zero_correct = True"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Take a single reading:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "reading, timestamp = elec.read()\n",
      "print \"Current Reading: {}\".format(reading)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Current Reading: 2.485788e-11 A\n"
       ]
      }
     ],
     "prompt_number": 7
    }
   ],
   "metadata": {}
  }
 ]
}